package org.longteng.security.service;

import org.longteng.core.base.TokenResult;
import org.longteng.security.vo.AuthorizationUserVo;
import org.longteng.security.vo.AuthorizationVo;

import javax.security.auth.message.AuthException;

/**
 * jwt密钥处理接口
 * @author hymn.com
 * @date 2022/12/07 10:00:00
 */
public interface JwtTokenService {
    public static final String PRIVATE_KEY_PATH = "token_Private_key";  // redis 私钥key
    public static final String PUBLIC_KEY_PATH  = "token_Public_key";  // redis 公钥key
    public static final String TOKEN_CLAIM_NAME_APPID  = "appId";  // jwt AuthorizationVo数据项name=appId
    public static final String TOKEN_CLAIM_NAME_SIGN  = "sign";    // jwt AuthorizationVo数据项name=sign


    /**
     * 生成token
     * @param authUserVo
     * @return
     */
    public TokenResult.TokenData buildToken(AuthorizationUserVo authUserVo) throws AuthException;

    /**
     * 验证token
     * @param token
     * @param authVo
     */
    public void verify(String token, AuthorizationVo authVo);

    /**
     * 刷新token,已过期的不能刷新
     * @param token
     * @return
     */
    public TokenResult.TokenData refreshToken(String token);

    /**
     * 记录在线token 到tokenOnlineCountMap
     * @param token
     */
    public void insertOlineToken(String token);
}
